package easy;

public class Solution_374 {

    public static int guessNumber(int n) {
        int begin = 1, end = n;
        for (; begin != end; ) {
            int mid = begin / 2 + end / 2 + (begin % 2 + end % 2) / 2;
            int r = guess(mid);
            if (r == 0) {
                return mid;
            } else if (r == -1) {
                end = mid - 1;
            } else {
                begin = mid + 1;
            }
        }
        return begin;
    }

    private static int guess(int num) {
        return num == 1702766719 ? 0 : num < 1702766719 ? 1 : -1;
    }

    public static void main(String[] args) {
        //2126753390
        //1702766719
        System.out.println(guessNumber(2126753390));
    }
}
